package com.cn.hz.zyj.mapper;

import com.cn.hz.zyj.model.entity.UserEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;

@Mapper
@Repository
public interface UserMapper {

    @Insert("INSERT INTO users values (NULL,#{username},#{realname},#{student_id},#{pwd_salt},#{pwd},#{pwd_valid_date}," +
            "#{user_type},#{pwd_error_count},#{class_id},#{grade_id})")
    public void addUser(UserEntity userEntity);

    @Select("select * from users")
    public List<UserEntity> selectAll();

    @Delete("delete from users where id = #{id}")
    public void deleteUser(int id);

    @Select("select * from users where id = #{id}")
    public UserEntity selectUser(int id);

    @Select("select * from users where username = #{username}")
    public UserEntity selectUserByUsername(String username);


}
